package edu.lehigh.cse.paclab.gameframework;
import org.anddev.andengine.entity.modifier.PathModifier.Path;
public class Scene {
	private int idNum;

	/**
	 * Strings that hold the name of the images for each level
	
	private String[] top = {"stalactite.png", "seaweed_top.png", "hill_top.png", "ballon_top.png", "sapce_top.png"};
	private String[] bottom = {"stalagmite.png", "seaweed_bottom.png","hill_bottom.png", "ballon_bottom.png", "space_bottom.png"};
	private String[] stat = {"lantern.png", "fish.png","gnome.png", "redball.png", "comet.png"};
	private String[] big = {"lantern_large.png", "fish_large.png","gnome_large.png", "redball.png", "comet_large.png",};
*/	
	private String[] top = {"stalactite.png", "red.png", "purple.png", "mustardball.png", "blueball.png"};
	private String[] bottom = {"stalagmite.png", "penguin.png", "turtle.png", "cat2.png", "cat.png"};
	private String[] stat = {"lantern.png", "redball.png", "redball.png", "redball.png", "redball.png"};
	private String[] big = {"lantern_large.png", "lantern_large.png","lantern_large.png", "lantern_large.png", "lantern_large.png",};

	private static int[] ids;
	private Obstacle[] obstacles;

	private Scene(int id, int trigId, int level){
		idNum = id;
		//obstacles = selectObstacles(id);
		//isUsed = false;
		addObstalces(id,trigId,level);
		//addObstalces(999,trigId,0);
	}


	public static Scene nextScene(int trigId, int level){
		//TEMP CHANGE TO HAVE GENERATE BETWEEN 1-14
		int randomNum = 1 + (int)(Math.random()*13);
		
		while(isUsedId(randomNum) || !difficultyMatch(randomNum, level)){
			randomNum = 1+(int)(Math.random()*13);
		}
		//Scene s = new Scene(999, 0, 0);
		Scene s= new Scene(randomNum, trigId, level);


		return s;
	}

	public int getIdNum(){
		return idNum;
	}

	private Obstacle[] selectObstacles(int id){
		/*
		 * if(id ==1){
		 * ect
		 * }
		 */
		// for now return null, later will return the chosen obstacle array
		return null;
	}
	public Obstacle[] getObstacles(){
		return obstacles;
	}

	void addObstalces(int id, int trigId, int level){
		//Goodie.addStationaryGoodie(300, 320-220, 0, 100, "purple.png");
		//id=0;
		switch (id){
		//Easy - big gaps
		case 1: 
			Enemy.addStationaryEnemy((trigId*460)+300, 320-220, 60, 220, bottom[level] , 0, 0, 0);
			//Goodie.addStationaryGoodie((trigId*460)+ 300, 0, 1, 100, "red.png");
			Enemy.addStationaryEnemy((trigId*460)+500, 0, 60, 200, top[level] , 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+700, 320-180, 60, 180, bottom[level] , 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+1000, 0, 60, 80, top[level] , 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+1000, 320-180, 60, 180, bottom[level] , 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+1300, 0, 60, 220, top[level] , 0, 0, 0);
			break;
			
		//Hard - Moving V's
		case 2:
			Enemy.addStationaryEnemy((trigId*460)+300, 320-150, 60, 150, bottom[level], 0, 0, 0);
			Enemy e1= Enemy.addMoveableBoxEnemy(300, 200, 40, 40, stat[level], 0, 0, 0);
			e1.applyPath(new Path(3).to((trigId*460)+200, 30).to((trigId*460)+200, 250).to((trigId*460)+200, 50), 3);

			Enemy e2 = Enemy.addMoveableBoxEnemy((trigId*460)+400, 250, 40, 40, stat[level], 0, 0, 0);
			e2.applyPath(new Path(5).to((trigId*460)+400, 250).to((trigId*460)+500, 50).to((trigId*460)+600, 250)
					.to((trigId*460)+500, 50).to((trigId*460)+400, 250), 5);

			Enemy e3 = Enemy.addMoveableBoxEnemy((trigId*460)+700, 250, 40, 40, stat[level], 0, 0, 0);
			e3.applyPath(new Path(5).to((trigId*460)+700, 250).to((trigId*460)+800, 50).to((trigId*460)+700, 250)
					.to((trigId*460)+600, 50).to((trigId*460)+700, 250), 5);

			Enemy e4 = Enemy.addMoveableBoxEnemy((trigId*460)+1000, 250, 40, 40, stat[level], 0, 0, 0);
			e4.applyPath(new Path(5).to((trigId*460)+1000, 250).to((trigId*460)+900, 50).to((trigId*460)+800, 250)
					.to((trigId*460)+900, 50).to((trigId*460)+1000, 250), 5);

			Enemy e5 = Enemy.addMoveableBoxEnemy((trigId*460)+1100, 250, 40, 40, stat[level], 0, 0, 0);
			e5.applyPath(new Path(5).to((trigId*460)+1100, 250).to((trigId*460)+1200, 50).to((trigId*460)+1100, 250)
					.to((trigId*460)+1000, 50).to((trigId*460)+1100, 250), 5);
			break;
			
		//Medium - Slower moving objects
		case 3: 
			Enemy.addStationaryEnemy((trigId*460)+200, 320-220, 60, 220, bottom[level] , 0, 0, 0);
			//Parallel Vertical
			Enemy.addMoveableBoxEnemy((trigId*460)+350, 60, 40, 40, stat[level] , 0, 0, 0)
			.applyPath(new Path(3).to((trigId*460)+350, 60).to((trigId*460)+350, 250).to((trigId*460)+350, 60),4);
			Enemy.addMoveableBoxEnemy((trigId*460)+450, 300, 40, 40, stat[level] , 0, 0, 0)
			.applyPath(new Path(3).to((trigId*460)+450, 280).to((trigId*460)+450, 50).to((trigId*460)+450, 280), 4);
			//Parallel Angle towards Down Right
			Enemy.addMoveableBoxEnemy((trigId*460)+550, 60, 40, 40, stat[level] , 0, 0, 0)
			.applyPath(new Path(3).to((trigId*460)+550, 60).to((trigId*460)+750, 250).to((trigId*460)+550, 60),4);
			Enemy.addMoveableBoxEnemy((trigId*460)+950, 250, 40, 40, stat[level] , 0, 0, 0)
			.applyPath(new Path(3).to((trigId*460)+950, 250).to((trigId*460)+750, 60).to((trigId*460)+950, 250),4);
			//Parallel Angle towards Down Left
			Enemy.addMoveableBoxEnemy((trigId*460)+1350, 60, 40, 40, stat[level] , 0, 0, 0)
			.applyPath(new Path(3).to((trigId*460)+1350, 60).to((trigId*460)+1150, 250).to((trigId*460)+1350, 60),4);
			Enemy.addMoveableBoxEnemy((trigId*460)+1000, 250, 40, 40, stat[level] , 0, 0, 0)
			.applyPath(new Path(3).to((trigId*460)+1000, 250).to((trigId*460)+1150, 60).to((trigId*460)+1000, 250),4);
			break;
			
		//EASY - Up&Down - child like even
		case 4:
			Enemy.addStationaryEnemy((trigId*460)+100, 0, 60, 150, top[level], 0, 0, 0);
			//Goodie.addStationaryGoodie((trigId*460)+ 100, 0, 1, 100, "red.png");
			Enemy.addStationaryEnemy((trigId*460)+300, 320-150, 60, 150, bottom[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+500, 0, 60, 150, top[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+700, 320-150, 60, 150, bottom[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+900, 0, 60, 150, top[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+1100, 320-150, 60, 150, bottom[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+1300, 0, 60, 150, top[level], 0, 0, 0);
			break;
		
		//Medium - Up&Down - precise timing
		case 5:
			Enemy.addStationaryEnemy((trigId*460)+100, 0, 60, 150, top[level], 0, 0, 0);	
			Enemy.addStationaryEnemy((trigId*460)+200, 320-150, 60, 150, bottom[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+300, 0, 60, 150, top[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+400, 320-150, 60, 150, bottom[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+500, 0, 60, 150, top[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+600, 320-150, 60, 150, bottom[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+700, 0, 60, 150, top[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+800, 320-150, 60, 150, bottom[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+900, 0, 60, 150, top[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+1000, 320-150, 60, 150, bottom[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+1100, 0, 60, 150, top[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+1200, 320-150, 60, 150, bottom[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+1300, 0, 60, 150, top[level], 0, 0, 0);
			break;

		//Easy - Pairs, go through "hoops"
		case 6:
			Enemy.addStationaryEnemy((trigId*460)+200, 0, 60, 80, top[level] , 0, 0, 0);	
			Enemy.addStationaryEnemy((trigId*460)+200, 320-160, 60, 160, bottom[level] , 0, 0, 0);
			
			Enemy.addStationaryEnemy((trigId*460)+500, 0, 60, 190, top[level] , 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+500, 320-50, 60, 50, bottom[level] , 0, 0, 0);
			
			Enemy.addStationaryEnemy((trigId*460)+800, 0, 60, 80, top[level] , 0, 0, 0);	
			Enemy.addStationaryEnemy((trigId*460)+800, 320-160, 60, 160, bottom[level] , 0, 0, 0);
			
			Enemy.addStationaryEnemy((trigId*460)+1100, 0, 60, 190, top[level] , 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+1100, 320-50, 60, 50, bottom[level] , 0, 0, 0);
			break;
			
		//Medium - Pairs, go through "hoops"
		case 7:
			Enemy.addStationaryEnemy((trigId*460)+200, 0, 60, 80, top[level], 0, 0, 0);	
			Enemy.addStationaryEnemy((trigId*460)+200, 320-160, 60, 160, bottom[level], 0, 0, 0);
			
			Enemy.addStationaryEnemy((trigId*460)+400, 0, 60, 190, top[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+400, 320-50, 60, 50, bottom[level], 0, 0, 0);
			
			Enemy.addStationaryEnemy((trigId*460)+600, 0, 60, 80, top[level], 0, 0, 0);	
			Enemy.addStationaryEnemy((trigId*460)+600, 320-160, 60, 160, bottom[level], 0, 0, 0);
			
			Enemy.addStationaryEnemy((trigId*460)+800, 0, 60, 80, top[level], 0, 0, 0);	
			Enemy.addStationaryEnemy((trigId*460)+800, 320-50, 60, 160, bottom[level]  , 0, 0, 0);
			
			Enemy.addStationaryEnemy((trigId*460)+1000, 0, 60, 190, top[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+1000, 320-160, 60, 50, bottom[level], 0, 0, 0);
			
			Enemy.addStationaryEnemy((trigId*460)+1200, 0, 60, 80, top[level], 0, 0, 0);	
			Enemy.addStationaryEnemy((trigId*460)+1200, 320-50, 60, 160, bottom[level], 0, 0, 0);

		//Medium - Vertical Lamps Different speeds
		case 8:
			Enemy.addMoveableBoxEnemy((trigId*460)+100, 60, 40, 40, stat[level] , 0, 0, 0)
			.applyPath(new Path(3).to((trigId*460)+100, 60).to((trigId*460)+100, 250).to((trigId*460)+100, 60),2);
			Enemy.addMoveableBoxEnemy((trigId*460)+300, 60, 40, 40, stat[level] , 0, 0, 0)
			.applyPath(new Path(3).to((trigId*460)+300, 60).to((trigId*460)+300, 250).to((trigId*460)+300, 60),3);
			Enemy.addMoveableBoxEnemy((trigId*460)+500,40, 40, 40, stat[level] , 0, 0, 0)
			.applyPath(new Path(3).to((trigId*460)+500, 60).to((trigId*460)+500, 250).to((trigId*460)+500, 60),4);
			Enemy.addMoveableBoxEnemy((trigId*460)+700, 60, 40, 40, stat[level] , 0, 0, 0)
			.applyPath(new Path(3).to((trigId*460)+700, 60).to((trigId*460)+700, 250).to((trigId*460)+700, 60),5);
			Enemy.addMoveableBoxEnemy((trigId*460)+900, 60, 40, 40, stat[level] , 0, 0, 0)
			.applyPath(new Path(3).to((trigId*460)+900, 60).to((trigId*460)+900, 250).to((trigId*460)+900, 60),4);
			Enemy.addMoveableBoxEnemy((trigId*460)+1100, 60, 40, 40, stat[level] , 0, 0, 0)
			.applyPath(new Path(3).to((trigId*460)+1100, 60).to((trigId*460)+1100, 250).to((trigId*460)+1100, 60),3);
			Enemy.addMoveableBoxEnemy((trigId*460)+1300,40, 40, 40, stat[level] , 0, 0, 0)
			.applyPath(new Path(3).to((trigId*460)+1300, 60).to((trigId*460)+1300, 250).to((trigId*460)+1300, 60),2);
			break;
		
		//Easy - Big Objects
		case 9:
			Enemy.addStationaryEnemy((trigId*460)+200, 210, 80, 80, big[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+400, 100, 80, 80, big[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+600, 200, 80, 80, big[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+800, 80, 80, 80, big[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+1000, 220, 80, 80, big[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+1200, 140, 80, 80, big[level], 0, 0, 0);
			break;
			
		//Easy - Big Objects weaving
		case 10:
			Enemy.addStationaryEnemy((trigId*460)+200, 60, 80, 80, big[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+300, 200, 80, 80, big[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+400, 60, 80, 80, big[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+500, 200, 80, 80, big[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+600, 60, 80, 80, big[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+700, 200, 80, 80, big[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+800, 60, 80, 80, big[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+900, 200, 80, 80, big[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+1000, 60, 80, 80, big[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+1100, 200, 80, 80, big[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+1200, 60, 80, 80, big[level], 0, 0, 0);
			Enemy.addStationaryEnemy((trigId*460)+1300, 200, 80, 80, big[level], 0, 0, 0);
			break;
			
		//Medium - Big Moving Objects
		case 11:
			Enemy.addMoveableBoxEnemy((trigId*460)+200, 2500, 65, 65, big[level] , 0, 0, 0)
			.applyPath(new Path(3).to((trigId*460)+200, 250).to((trigId*460)+200, 30).to((trigId*460)+200, 250),4);
			Enemy.addMoveableBoxEnemy((trigId*460)+400,40, 65, 65, big[level] , 0, 0, 0)
			.applyPath(new Path(3).to((trigId*460)+400, 30).to((trigId*460)+400, 250).to((trigId*460)+400, 30),4);
			Enemy.addMoveableBoxEnemy((trigId*460)+600, 30, 65, 65, big[level] , 0, 0, 0)
			.applyPath(new Path(3).to((trigId*460)+600, 30).to((trigId*460)+600, 250).to((trigId*460)+600, 30),4);
			Enemy.addMoveableBoxEnemy((trigId*460)+800,40, 65, 65, big[level] , 0, 0, 0)
			.applyPath(new Path(3).to((trigId*460)+800, 30).to((trigId*460)+800, 250).to((trigId*460)+800, 30),4);
			Enemy.addMoveableBoxEnemy((trigId*460)+1000,40, 65, 65, big[level] , 0, 0, 0)
			.applyPath(new Path(3).to((trigId*460)+1000, 30).to((trigId*460)+1000, 250).to((trigId*460)+1000, 30),4);
			Enemy.addMoveableBoxEnemy((trigId*460)+1300,40, 65, 65, big[level] , 0, 0, 0)
			.applyPath(new Path(3).to((trigId*460)+1300, 30).to((trigId*460)+1300, 250).to((trigId*460)+1300, 30),3);
			break;
			
		//Hard - Fast Movements
		case 12:
			Enemy.addMoveableBoxEnemy((trigId*460)+200,40, 40, 40, stat[level] , 0, 0, 0)
			.applyPath(new Path(4).to((trigId*460)+200, 250).to((trigId*460)+200, 30)
					.to((trigId*460)+1300, 250).to((trigId*460)+200, 250),5);
		
			Enemy.addMoveableBoxEnemy((trigId*460)+1300,40, 40, 40, stat[level] , 0, 0, 0)
			.applyPath(new Path(4).to((trigId*460)+1300, 250).to((trigId*460)+1300, 30)
					.to((trigId*460)+200, 250).to((trigId*460)+1300, 250),5);
			break;
			
		//Medium - Big moving in squares
		case 13:
			Enemy.addMoveableBoxEnemy((trigId*460)+200, 250, 65, 65, big[level] , 0, 0, 0)
			.applyPath(new Path(5).to((trigId*460)+200, 250).to((trigId*460)+200, 30)
					.to((trigId*460)+400, 30).to((trigId*460)+400, 250).to((trigId*460)+200, 250),5);
		
			Enemy.addMoveableBoxEnemy((trigId*460)+600, 40, 65, 65, big[level] , 0, 0, 0)
			.applyPath(new Path(5).to((trigId*460)+600, 30).to((trigId*460)+600, 250)
					.to((trigId*460)+800, 250).to((trigId*460)+800, 30).to((trigId*460)+600, 30),5);
			
			Enemy.addMoveableBoxEnemy((trigId*460)+1000,40, 65, 65, big[level] , 0, 0, 0)
			.applyPath(new Path(5).to((trigId*460)+1000, 250).to((trigId*460)+1000, 30)
					.to((trigId*460)+1200, 30).to((trigId*460)+1200, 250).to((trigId*460)+1000, 250),5);
			break;
			
		//Easy - Tight Squeezes
		case 14:
			Enemy.addStationaryEnemy(100, 0, 100, 100, top[level], 0, 0, 0);
			Enemy.addStationaryEnemy(100, 220, 100, 100, big[level], 0, 0, 0);
			Enemy.addStationaryEnemy(200, 0, 100, 120, top[level], 0, 0, 0);
			Enemy.addStationaryEnemy(300, 0, 100, 180, top[level], 0, 0, 0);
			Enemy.addStationaryEnemy(400, 0, 100, 220, top[level], 0, 0, 0);
			Enemy.addStationaryEnemy(500, 0, 100, 220, top[level], 0, 0, 0);
			Enemy.addStationaryEnemy(600, 0, 100, 180, top[level], 0, 0, 0);
			Enemy.addStationaryEnemy(700, 0, 100, 120, top[level], 0, 0, 0);
			Enemy.addStationaryEnemy(800, 0, 100, 100, top[level], 0, 0, 0);
			Enemy.addStationaryEnemy(800, 220, 100, 100, big[level], 0, 0, 0);
			Enemy.addStationaryEnemy(900, 0, 100, 120, top[level], 0, 0, 0);
			Enemy.addStationaryEnemy(1000, 0, 100, 180, top[level], 0, 0, 0);
			Enemy.addStationaryEnemy(1100, 0, 100, 220, top[level], 0, 0, 0);
			Enemy.addStationaryEnemy(1200, 0, 100, 220, top[level], 0, 0, 0);
			Enemy.addStationaryEnemy(1300, 0, 100, 180, top[level], 0, 0, 0);
			break;
			
		//End Scene to Force player to destination object
		case -1:
			Enemy.addStationaryEnemy(1350, 320-260, 30, 260, bottom[level], 0, 0, 0);
			Enemy.addStationaryEnemy(1320, 320-240, 30, 240, bottom[level], 0, 0, 0);
			Enemy.addStationaryEnemy(1290, 320-220, 30, 220, bottom[level], 0, 0, 0);
			Enemy.addStationaryEnemy(1260, 320-200, 30, 200, bottom[level], 0, 0, 0);
			Enemy.addStationaryEnemy(1230, 320-180, 30, 180, bottom[level], 0, 0, 0);
			Enemy.addStationaryEnemy(1200, 320-160, 30, 160, bottom[level], 0, 0, 0);
			Enemy.addStationaryEnemy(1170, 320-140, 30, 140, bottom[level], 0, 0, 0);
			Enemy.addStationaryEnemy(1140, 320-120, 30, 120, bottom[level], 0, 0, 0);
			Enemy.addStationaryEnemy(1110, 320-100, 30, 100, bottom[level], 0, 0, 0);
			Enemy.addStationaryEnemy(1080, 320-80, 30, 80, bottom[level], 0, 0, 0);
			Enemy.addStationaryEnemy(1050, 320-40, 30, 40, bottom[level], 0, 0, 0);
			Enemy.addStationaryEnemy(1020, 320-20, 30, 20, bottom[level], 0, 0, 0);
			break;

		}

		//will add obstacles with the dimensions in the array
		//MAYBE DOUBLE FOR SELECTOBSTACLES
		//when selected they are automatically added to the screen so we could skip a step
		//wouldnt need obstacles instance variable then ..... 
	}


	static void setIds(){
		int[] id = new int[20];
		for(int i = 0; i < 20; i++){
			id[i] = i+1;
		}
		ids = id;
	}

	static boolean isUsedId(int i){
		for(int j = 0; j < 15; j++){
			if(ids[j] == i){
				ids[j] = 0;
				return true;
			}
		}
		return false;
	}
	static boolean difficultyMatch(int randomNum, int level){
		String difficulty;
		if(randomNum == 3 || randomNum == 5 || randomNum == 7 || randomNum == 8 || randomNum == 11 || randomNum ==13)
			difficulty = "medium";
		else if(randomNum == 1 || randomNum == 4 || randomNum == 6 || randomNum == 9 || randomNum == 10 || randomNum ==14)
			difficulty = "easy";
		else
			difficulty = "hard";
		if(difficulty.equals("easy") && (level == 1 || level == 2 || level == 3))
			return true;
		else if(difficulty.equals("medium") && (level == 2 || level == 3 || level == 4))
			return true;
		else if(difficulty.equals("hard") && (level == 4 || level == 5))
			return true;
		else
			return false;
	}
}
